#pragma once

#include "HashedString.h"
#include "RigidBody.h"
#include "C:\Bullet\src\btBulletDynamicsCommon.h"
#include <map>

class System
{
public:
	typedef std::map<HashedString, Pointer<System>> Map_t;
	typedef std::pair<HashedString, Pointer<System>> Pair_t;

	System();
	~System();

	void Initialize();
	void Deinitialize();

	void Evaluate( float timeChange );
	void PrintObjects();

	void AddRigidBody( RigidBody* body );
	void RemoveRigidBody( RigidBody* body );
	
	void setGravity( float x, float y, float z );
	void setGravity( Maths::Vector3D& gravity );

	bool RayCast( Maths::Vector3D& start, Maths::Vector3D& end, void** pointer );
	bool RayCastGetPoint( Maths::Vector3D& start, Maths::Vector3D& end, void** pointer, Maths::Vector3D& point );
protected:
	RigidBody::List_t m_bodies;

	btBroadphaseInterface* m_broadphase;
	btCollisionDispatcher* m_dispatcher;
	btDefaultCollisionConfiguration* m_collisionConfiguration;
	btSequentialImpulseConstraintSolver* m_solver;
	btDiscreteDynamicsWorld* m_dynamicsWorld;
};